#include <iostream>
#include <pthread.h>

namespace mymutex
{
    class mutex
    {
    public:
        mutex()
        {
            pthread_mutex_init(&_mutex, nullptr);
        }
        void Lock()
        {
            pthread_mutex_lock(&_mutex);
        }
        void Unlock()
        {
            pthread_mutex_unlock(&_mutex);
        }
        ~mutex()
        {
            pthread_mutex_destroy(&_mutex);
        }

    private:
        pthread_mutex_t _mutex;
    };
    class lockgroup
    {
    public:
        lockgroup()
        {
            _mutex.Lock();
        }
        ~lockgroup()
        {
            _mutex.Unlock();
        }

    private:
        mutex _mutex;
    };
}